﻿<?php
session_start();
include("../../corePage/common.php");
header('Content-type:application/json;charset=UTF-8');
header("Access-Control-Allow-Origin: $domainName");
#获取用户名密码
$sys_username = trims($_REQUEST['sys_username']);
$sys_password = trims($_REQUEST['sys_password']);
$sys_username = "admin";
$sys_password = "admin";
#验证用户权限级别
$userObject = null;
$sys_level = null;
if(isset($sys_username) && isset($sys_password) ){
	$sql="select * from ".$database_prefix."_".$userTableName." where ".$username_field." = '$sys_username' and ".$password_field." = '$sys_password'";
	$userObject = select_Object($sql);
}elseif(isset($_SESSION['sys_level'])){
	$sys_level = $_SESSION['sys_level'];
}else{
	#未登录
	echo '{"status":"error","errorCode":"10"}';
	return false;
}
if($userObject || $sys_level){
	#权限大于等于1023
	if(isset($userObject)){
		$sys_level = $userObject['level'];
	}
	if((int)$sys_level  >= 1023){
		$sql="select * from ".$database_prefix."_".$userTableName." where level < '$sys_level'";
		$userObjectList = select_ObjectList($sql);
		if($userObjectList){
			arrayRecursive($userObjectList, 'urlencode',false);
            echo trim(urldecode(json_encode($userObjectList)));
		}else{
			#查无数据[112]
			echo '{"status":"error","errorCode":"112"}';
		}
	}else{
		#权限不够[113]
		echo '{"status":"error","errorCode":"113"}';
	}
}else{
	#用户验证失败[114]
	echo '{"status":"error","errorCode":"114"}';
}
?>

